package com.ogilvy.audi.dao.hibernate;

import java.util.List;
import java.util.Map;

import com.ogilvy.audi.model.CircleTopic;
import com.ogilvy.audi.dao.CircleTopicDao;
import com.ogilvy.audi.dao.hibernate.GenericDaoHibernate;
import org.springframework.stereotype.Repository;

@Repository("circleTopicDao")
public class CircleTopicDaoHibernate extends GenericDaoHibernate<CircleTopic, Long> implements CircleTopicDao {

    public CircleTopicDaoHibernate() {
        super(CircleTopic.class);
    }
    public List<CircleTopic> query(Map<String,Object> condition){
    	StringBuffer hql = new StringBuffer("from CircleTopic where 1=1");
		if(condition.get("circleId")!=null){
			hql.append(" and circleId =").append(condition.get("circleId"));
		}
		return this.getSessionFactory().getCurrentSession().
		 createQuery(hql.toString()).list();
    }
}
